<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let c = 30;
        // 块级作用域
        {
            {
                let a = 10;
                var b = 20;
            }
            // console.log(a);
        }
        // console.log(a);
        console.log(b);

        // =================
        for(var i = 0; i < 5; i ++) {
            console.log(i);
        }
        console.log(i);
        for(let j = 0; j < 5; j ++) {
            console.log(j);
        }
        // console.log(j); j not defined是因为这个变量被销毁了 找不到了

        var aaa = [];
        for(var ii = 0; ii<10; ii ++) {
            aaa[ii] = function() {
                console.log(ii);
            }
        }
        // console.log(ii);
        // aaa[4]()

        var aa = [];
        for(let jj = 0; jj<10; jj ++) {
            aa[jj] = function() {
                console.log(jj);
            }
        }
        // console.log(jj);
        aa[2]()
    </script>
</body>

</html>